{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin static %}
{% load ballot_icon %}
{% load ietf_filters person_filters %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block title %}IESG discuss positions{% endblock %}
{% block content %}
    {% origin %}
    <h1>IESG discuss positions</h1>
    {% include "iesg/nav.html" with active="discusses" %}
    {% if user|has_role:"Area Director" %}
        <div class="btn-group my-3" role="group" aria-label="Choose DISCUSSes">
            <input type="radio"
                   class="btn-check"
                   autocomplete="off"
                   name="btnradio"
                   value="all"
                   id="all"
                   checked>
            <label for="all" class="btn btn-outline-primary discuss">All</label>
            <input type="radio"
                   class="btn-check"
                   autocomplete="off"
                   name="btnradio"
                   value="byme"
                   id="byme">
            <label for="byme" class="btn btn-outline-primary discuss">By me</label>
            <input type="radio"
                   class="btn-check"
                   autocomplete="off"
                   name="btnradio"
                   value="forme"
                   id="forme">
            <label for="forme" class="btn btn-outline-primary discuss">For me</label>
        </div>
    {% endif %}
    <table class="table table-sm table-striped tablesorter">
        <thead>
            <tr>
                <th scope="col" data-sort="document">Document</th>
                <th scope="col" data-sort="status">Status</th>
                <th scope="col" data-sort="ad" class="d-none d-sm-table-cell">Responsible AD</th>
                <th scope="col" data-sort="discusses">Discusses</th>
            </tr>
        </thead>
        <tbody id="doclist">
            {% for doc in docs %}
                <tr class="{% if doc.by_me %}
                               byme
                           {% endif %}

                           {% if doc.for_me %}
                               forme
                           {% endif %}">
                    <td>{{ doc.displayname_with_link }}</td>
                    {% include "doc/search/status_columns.html" %}
                    <td class="d-none d-sm-table-cell">{% person_link doc.ad %}</td>
                    <td>
                        {% for p in doc.blocking_positions %}
                            {% if p.is_old_pos %}<span class="text-body-secondary">{% endif %}
                            {% person_link p.balloter %}
                            ({% if p.discuss_time %}{{ p.discuss_time|timesince_days }} days ago{% endif %}{% if doc.get_state_url != "rfc" and p.rev != doc.rev %} for -{{ p.rev }}{% endif %})
                            <br>
                            {% if p.is_old_pos %}</span>{% endif %}
                        {% endfor %}
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
{% endblock %}
{% block js %}
    <script src="{% static "ietf/js/list.js" %}"></script>
    <script>
        $(".discuss").on("click", function () {
            var x = $(this).prev("input").val();
            if (x === "all") {
                $("#doclist>tr").removeClass("d-none");
            } else {
                $("#doclist>tr." + x).removeClass("d-none");
                $("#doclist>tr:not(." + x + ")").addClass("d-none");
            }
        });
    </script>
{% endblock %}
